package lesson19.notepad;

public class Page {
	private final String title;
	private String text= "";
	
	Page(String title) {
		if(title != null)
			this.title = title;
		else
		{
			System.out.println("Wrong title format!");
			this.title = "";
		}
	}
		
	void addText(final String text)
	{
		if(this.text != null)
			this.text = this.text.concat(text);
		else
			this.text = text;
	}
	
	void deleteText()
	{
		this.text = "";
	}
	
	String getPageInfo()
	{
		String output = this.title + "\n" + this.text;
		return output;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj != null && obj instanceof Page)
		{
			return ((Page) obj).title.equals(this.title);
		}
		else
			return false;
	}
}


